// OsgPlotter.h - MARIN MSG Anneke Sicherer-Roetman 200xyyzz


// LIN_WACU

#ifndef OSGPLOTTER_H
#define OSGPLOTTER_H

#include <vector>
#include <map>
#include <mml/Vector.h>
#include "Plotter.h"
#include "OsgViewer.h"

#define OSGPLOTTER_BASE Plotter

/// OpenSceneGraph plotting class 
/** uses osg::HeightField to display water surface */
class OsgPlotter : public OSGPLOTTER_BASE
{
    typedef OSGPLOTTER_BASE base;
    
public:
    
    OsgPlotter(int xmin, int ymin, int xmax, int ymax,
               float dx1, float dx2, const Array2D<float> &plot, const std::string &caption);
    
    virtual ~OsgPlotter();
    
    void plot();
    
    void run();

    void setCaption(const std::string& caption);

    void setZview();

    void setZscale(float factor);
    
    void setDistance(float distance);

    void setLeftClickHandler(osgviewer::ClickHandler handler);
    
    void setRightClickHandler(osgviewer::ClickHandler handler);

    void addObject(const std::string &name, const std::string &type, const std::string &color,
                   float diameter, float x1, float y1, float z1, float x2 = osgviewer::defpos.x(),
                                                                 float y2 = osgviewer::defpos.y(),
                                                                 float z2 = osgviewer::defpos.z());
    
    void addPanelRoot(const std::string &name);

    void addPanel(const std::string &rootname, const std::string &color,
                  const std::vector<mml::Vector3d>& vertices,
                  const mml::Vector3d& normal);

    void moveObject(const std::string &name, float x, float y, float z);

    void rotateObject(const std::string &name, float x, float y, float z);

    bool removeObject(const std::string &name);

    void removeAllObjects();

    void addAxes(const osg::Vec3 axes, float length, float ticks);

    void toggleScreenCast();

    void toggleLightDirection();

private:
    
    /// @cond nevercall
    OsgPlotter();
    OsgPlotter(const OsgPlotter& m);
    OsgPlotter& operator=(const OsgPlotter& m);
    /// @endcond
    
    osgviewer::OsgViewer *m_pViewer;              ///< plot window
};

#endif // OSGPLOTTER_H
